package com.ruoyi.service.code.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.core.enums.YesNoEnum;
import com.ruoyi.service.code.entity.InviteCodeEntity;
import com.ruoyi.service.code.mapper.InviteCodeMapper;
import com.ruoyi.service.code.service.InviteCodeService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 邀请码 服务实现类
 * </p>
 *
 * @author Zane
 * @since 2025-10-20
 */
@Service
public class InviteCodeServiceImpl extends ServiceImpl<InviteCodeMapper, InviteCodeEntity>
    implements InviteCodeService {

  @Override
  public InviteCodeEntity getByInviteCode(String inviteCode) {
    return  getOne(queryWrapper().eq(InviteCodeEntity::getInviteCode, inviteCode)
        .eq(InviteCodeEntity::getCheckedFlag, YesNoEnum.NO.getCode()));
  }
  private LambdaQueryWrapper<InviteCodeEntity> queryWrapper() {
    return new LambdaQueryWrapper<>();
  }
}
